<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport"
	      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>居中</title>
	<style>
		.container{
			width: 1000px;
			height: 500px;
			position: relative;
			border: 1px solid saddlebrown;
			/*第四种
			display: flex;
			justify-content: center;
			align-items: center;
			*/

			/*第五种*/
			display: grid;
			align-content: center;
			justify-content: center;

		}
		#box{
			width: 300px;
			height: 300px;
			background: #42b983;
      /*第一种
			position: absolute;
			left: 0;
			top: 0;
			right: 0;
			bottom: 0;
			margin: auto;
			*/
			/*第二种
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%,-50%);
			*/
			/*第三种
			position: absolute;
			left: 50%;
			top: 50%;
			margin-left: -150px;
			margin-top: -150px;
			*/
			/*第四种*/
		}
	</style>
</head>
<body>
<div class="container">
	<div id="box">

	</div>
</div>

</body>
</html>
